package learning.timer_timerTask;

import java.util.Timer;
import java.util.TimerTask;

public class Timer_TimerTask1 {
	public static void main(String[] args) {
		Timer t = new Timer();
		t.schedule(new TimerTask() {
			int index = 0;
			String[] strs = { "Tayle will come to China",
					"Japan was attached yesterday","President of UK annouced to leave" };

			@Override
			public void run() {
				System.out.println(strs[index]);
				index++;
				if (index == strs.length)
					index = 0;
			}
		}, 0, 2000);
	}

}
